<script>
	import {
		mapActions,
		mapMutations
	} from 'vuex'
	import {
		getUrlParam,
		getUrlPath
	} from '@/common/js/common.js'
  import { wxChat } from '@/utils/wxConfig.js'
  
	export default {
		onLaunch: function(e) {
			//  #ifdef MP-WEIXIN
			this.wxGetAppId(); // 获取当前帐号信息。线上小程序版本号仅支持在正式版小程序中获取，开发版和体验版中无法获取
			// #endif 

			// #ifdef MP-ALIPAY
			this.alGetAppId()
			// #endif

			// 登录绑定信息 针对消息推送
			this.$global.appLogin().then(data => {
				this.$isResolve()
			}).catch(e => {
				this.$isResolve()
			})
			// #ifdef H5
			const newPatId = e.query.patId
			console.log(e)
			const apptype = getUrlParam('app_type') || '20241015'
			this.SET_APPID(apptype)
			// 登录绑定信息 针对消息推送
			const code = getUrlParam('code') || 1
			// const code =wx05ed6d3eec005b7d
			if (code) {
				this.getUserId(code).then(s => {
					this.$isResolve()
				}).catch(e => {
					this.$isResolve()
				})
			}
			// #endif
			this.getHospitalInfo() // 请求医院信息
			// this.getParams(); //请求数据字典配置
      wxChat()
		},
		globalData: {
			test: ''
		},
		methods: {
			...mapActions(['getParams', , 'getHospitalInfo', 'getUserId']),
			...mapMutations(['SET_APPID']),
			alGetUserInfo() { // 支付宝的
				uni.getUserInfo({
					provider: 'alipay', // 登录服务提供商先写死
					success: (result) => {
						console.log('getUserInfo success', result);
					},
					fail: (error) => {
						console.log('getUserInfo fail', error);
						let content = error.errMsg;
						if (content.indexOf('uni.login')) {
							content = '请在登录页面完成登录操作';
						}
						// ...
					}
				});
			},
			alGetAppId() {
				const appIdRes = my.getAppIdSync()
				// const appIdRes2 = uni.getAccountInfoSync()
				// this.SET_APPID('2021004103625029')
				if (appIdRes) {
					this.SET_APPID(appIdRes.appId)
				}
			},
			wxGetAppId() {
				const accountInfo = wx.getAccountInfoSync()
				if (accountInfo && accountInfo.miniProgram) {
					this.SET_APPID(accountInfo.miniProgram.appId)
				}
			}
		}
	}
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	// @import  url('https://at.alicdn.com/t/font_2545549_q67sf7u0knq.css');
	// @import '@/node_modules/uview-ui/index.scss';
	@import "common/font/iconfont.css";
	@import "uview-ui/index.scss";
	@import "common/style/common.scss";

	page {
		// height: 100%;
		// background-color:$bg-color-base;
		// background: linear-gradient(#d1e1ff 0, #F5F9FF 40%, #F5F9FF 50%) no-repeat;
		// overflow: auto;
		// background-image: url($mk-base+"/static/images/bg.png");
		// background-size: 100% 400px;
		// background-repeat: no-repeat;
	}

	// .page {
	// 	height: 100vh;
	// 	padding: 32upx;
	// 	overflow: auto;
	// }

	// .card-page {
	// 	height: 100vh;
	// 	padding: 32upx;
	// 	overflow: auto;
	// 	background: url('static/images/bg-header/page_bk1.png') no-repeat, linear-gradient(#d1e1ff 0, #F5F9FF 40%, #F5F9FF 50%) no-repeat;
	// 	background-size: 100%;
	// }
</style>